Example-Based Live Programming for Everyone (2020)
前提
Example-Based Live Programming (ELP) とは
While programmers write code, an elp system uses user-provided examples to invoke annotated functions, and to provide fine-grained, live feedback on the resulting program behavior.
Babylonian programming system とは
Programming system, programmers can define multiple, named examples for each function or method in JavaScript (js)
hr.icon
どんなもの?
Example_Based Live Programming system はこれまで特定のプログラミング言語やインタープリターやIDEに密結合だった、Truffle と LSP を使って multiple programming language and multiple editor に対して簡単にシステムを使えるようにする
code comment の中に probe (doctest みたいな感じ) を埋め込めるようにした (VCS 使って共有できるように)
XML-like な DSL を定義して、その中に書いてもらう
code:js
// < Example : name =" hot " inputValue =95 / >
function getTemperatureText (inputValue) {
// < Probe : example =" hot " / >
return ${ inputValue }◦F equals ${ toCelsius ( inputValue )}◦C
}
// < Example : name =" cold " fahrenheit =32 / >
function toCelsius (fahrenheit) {
// < Probe : expression =" fahrenheit - 32" / >
// < Assertion : example =" cold " : expected =0 / >
return (fahrenheit - 32) * 5/9
}
hr.icon
先行研究と比べてどこがすごい?
先行研究のELP systemは特定のプログラミング言語、エディタ上でしか動かなかった、それが原因で広く使われるシステムを作ることができていなかった。この研究ではTruffleとLSPを使ってpolyglotかつ editor wide なプログラミング環境を作った
hr.icon
技術や手法のキモはどこ?
hr.icon
どうやって有効だと検証した?
複数のプログラミング言語(JS/Ruby/SimpleLanguage)で babylonian programming system を作ることで、live programming system が LSP (と Truffle)によって langauge agnostic に作れることを実証した
LSP や editor 側の制約によりいくつかの機能がなくなってしまうものの
hr.icon
議論はある?
Three major features are currently missing from our prototype:
navigating the trace
The trace navigation as supported by the original Babylonian Programming system faces more fundamental challenges resulting from the features of VS Code
inspecting complex objects, and
specifying context beyond an isolated execution environment
The specification of context and an inspector for complex objects are possible but not implemented yet due to time constraints
sliders and embedded graphical editors が missing
VSCode にそういうrich UIを表示する機能がない
今後は
https://scrapbox.io/files/6097ed4869c3da001f3350f1.png
hr.icon
感想
didSave したら即座に実行されてフィードバックが得られる
実行時情報が得られるので便利
ここが大きいのかな
しかし、こういうlive性ってそんなに必要か? ほしいと思ったことはあまりない気がする。プログラミング初学者とかは嬉しいのかな...
code example が欲しいコードは自分が書いているコードではなくて、まったくの他人が書いた、3rdパーティライブラリのAPIのexampleがほしいんだよな、
多分このツールは自分が関数を定義している or modify しているときにコードexampleを即座に実行したり実行の過程を見たりするのに便利よいう話
仕事であまり使いたいかというと微妙...なぜなら独自DSLをコメントに書かないといけないから、コメントのフォーマットは広く受け入れられたフォーマットが望ましい
研究プロジェクトだし、フォーマットを提案しているという話なのでそこは重要ではない
次に読むべき論文は?
Live Programming とか Exploratory programming のいろいろまとめ
Babylonian Programming
Example Centric Programming のもと
過去のELPシステム
Eclipse plug-in / modified, tracingjvm
specialized code editor / manual instrumentation
Emacs plug-in / new language, tracing execution environment
specialized code editor / unknown
specialized code editor / unknown
specialized code editor / code rewriting
VCS extension / unknown